package personal.wang.juc.juc;


import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @className: Deadlock
 * @Description:
 * @Author: wangyifei
 * @Date: 2025/3/21 17:58
 */
public class Deadlock {
    public static void main(String[] args) throws IOException {
        ReentrantLock lock1 = new ReentrantLock();
        ReentrantLock lock2 = new ReentrantLock();
        lock1.lock();
        Thread thread1 = new Thread(()->{
            try {
                Thread.sleep(1000L);
                lock1.tryLock(2 , TimeUnit.SECONDS);
                System.out.println("no lock");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        thread1.start();
        System.in.read();
    }
}
